<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/jquery-ui.css">
    <link rel="stylesheet" href="css/easyui.css">
    <script type="text/javascript" src="js/lib/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="js/lib/jquery-ui.js"></script>
    <script type="text/javascript">
        /**
         * 初始化
         */
        $(function () {
            //按钮样式
            $("#takePhoto").button()
                .click(function (event) {
                    event.preventDefault();
                });
        });


        /**
         * 拍照
         */
        function photo() {

            var camObj = document["My_Cam"];
            var base64Data = camObj.GetBase64Code();
            console.info(base64Data);

            //展示
            var src = "data:image/png;base64," + base64Data;
            $("#img-photo").attr("src", src);


            //保存到后台
            /*$.restPost({
                type:'post',
                dataType: 'json',
                url:'../photo/save',
                data:{photo：base64Data},
                success:function(data){
                    alert(data);
                }
            });*/

        }

        /**
         * 获取url请求参数
         */
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }
    </script>
</head>
<body>
<!-- FLASH调用 -->
<div id="FalshDiv" style="text-align:center;">
    <object style="z-index: 100" id="My_Cam" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
            codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
            height="400" viewastext="在线拍照" width="500">
        <param name="allowScriptAccess" value="sameDomain"/>
        <param name="movie" value="js/lib/camera.swf"/>
        <param name="quality" value="high"/>
        <param name="bgcolor" value="#ffffff"/>
        <param name="wmode" value="transparent"/>
        <embed style="z-index: 100" align="middle" allowscriptaccess="sameDomain" bgcolor="#ffffff" height="400"
               name="My_Cam" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high"
               wmode="transparent"
               src="js/lib/camera.swf" type="application/x-shockwave-flash" width="500"></embed>
    </object>
</div>
<!-- 执行按钮 -->
<div align="center">
    <input id="takePhoto" type="button" value="拍照" onclick="photo()">
</div>
<div align="center">
    <img id="img-photo">
</div>
</body>
</html>